<?php include("QuestionAssembler.php");
      include("Question.php");

   $questionStr = "%ax^2 + %bx + %c = 0";
   $answerStr = "x = (%f, %g)";
   $dataDef = "f = random(-5, 5, makeSet(0));
   	       g = random(-5, 5, makeSet(0, -1 * %f));
	       a = 1;
	       b = -1*%f + -1*%g;
	       c = %f * %g;";
   $solutionFn = "equals";
   $solution = "makeArray(%f, %g);";
   $template = new QuestionAssembler();
   $defn = new QuestionDefinition($dataDef, 
				  $questionStr, 
				  $answerStr, 
				  $solution, 
				  $solutionFn, 
				  2);

   $template->build($defn);

   $soln = $template->getTestQuestion();
   print $soln->question."<br>";
   print $soln->answer."<br>";
   print $soln->solve("5; 5");
   print "<br><br>";

   $questionStr = "%g + %h";
   $answerStr = "%i";
   $dataDef = "b = random(2,10, makeSet(0));
   	       d = factor(%b);
	       a = random(1, %b-1, makeSet(0));
	       c = random(1, %d-1, makeSet(0));
	       f = lcd(%b, %d);
	       e = %f/%b * %a + %f/%d * %c;
	       g = reduce(%a,%b);
	       h = reduce(%c,%d);
	       i = reduce(%e,%f);";
   $solutionFn = "equalFractions";
   $solution = "makeArray(reduce(%e,%f));";

   $template = new QuestionAssembler();
   $defn = new QuestionDefinition($dataDef, 
				  $questionStr, 
				  $answerStr, 
				  $solution, 
				  $solutionFn, 
				  2);
   $template->build($defn);

   $soln = $template->getTestQuestion();
   print $soln->question."<br>";
   print $soln->answer."<br>";
   print $soln->solve("3/2");
   print "<br><br>";

   $questionStr = "%ax + %by = %c<br>%dx + %ey = %f";
   $answerStr = "x=%x, y=%y";
   $dataDef = "x = random(-5,5, makeSet(0));
   	       y = random(-5,5, makeSet(0));
	       a = random(-5,5, makeSet(0));
	       b = random(-5,5, makeSet(0));
	       c = %a * %x + %b * %y;
	       d = random(-5,5, makeSet(0));
	       e = random(-5,5, makeSet(0));
	       f = %d * %x + %e * %y;";
   $solutionFn = "equals";
   $solution = "makeArray(%x, %y);";

   $template = new QuestionAssembler();
   $defn = new QuestionDefinition($dataDef, 
				  $questionStr, 
				  $answerStr, 
				  $solution, 
				  $solutionFn, 
				  0);

   $template->build($defn);

   $soln = $template->getTestQuestion();
   print $soln->question."<br>";
   print $soln->answer."<br>";
   print $soln->solve("-5; 1");
   print "<br><br>";

   $questionStr = "%a + %b = ?<br>(a) %c (b) %d (c) %e (d) %f";
   $answerStr = "(c)";
   $dataDef = "a = random(1, 5);
   	       b = random(1, 5);
	       c = %a - %b;
	       d = %a - %b - 1;
	       e = %a + %b;
	       f = %a + %b + 1;";
   $solutionFn = "equals";
   $solution = "makeArray(\"c\");";
   $template = new QuestionAssembler();
   $defn = new QuestionDefinition($dataDef, 
				  $questionStr, 
				  $answerStr, 
				  $solution, 
				  $solutionFn, 
				  0);
   $template->build($defn);
   $soln = $template->getTestQuestion();
   print $soln->question."<br>";
   print $soln->answer."<br>";
   print $soln->solve("c");

?>